Help Emma detect similarities in student documents by finding the LCS
Emma needs to find all unique Longest Common Subsequences (LCS) between two document strings and their length to detect similarities.
doc1:
doc2:
LCS: "is test" (Length: 7)
| i | s | t | e | s | t | T | h | i | s | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
| T | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| h | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 2 | 2 |
| i | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 3 | 3 |
| s | 0 | 1 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 3 | 4 |
| 0 | 1 | 2 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 4 | |
| t | 0 | 1 | 2 | 3 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 |
| e | 0 | 1 | 2 | 3 | 4 | 5 | 5 | 5 | 5 | 5 | 5 | 5 | 5 |
| s | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 6 | 6 | 6 | 6 | 6 | 6 |
| t | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 7 | 7 | 7 | 7 | 7 |
LCS: "is test" (Length: 7)
For building DP table
For DP table and results
doc1:
doc2:
Example 1: doc1 = "This is test", doc2 = "is test This" → LCS: "is test", Length: 7
Example 2: doc1 = "The brown quick fox", doc2 = "The quick brown fox" → LCS: "The brown fox", "The quick fox", Length: 13
For building DP table
For DP table and results